import type { Request, ResponseToolkit } from "@hapi/hapi";
import Hapi from "@hapi/hapi";
import { Routes, roles } from "../../model/index";
let route: Hapi.ServerRoute<Hapi.ReqRefDefaults> = {
  path: "/getRouteList",
  method: "get",
  handler: async (r: any, h: ResponseToolkit) => {
    try {
      console.log(r.query, "r.query.id", r.query["id[]"]);
      const routeList: any = await roles
        .find({
          _id: { $in: r.query["id[]"] },
        })
        .populate("route");
      console.log(routeList, "routeList");
      return { code: 200, data: routeList, message: "" };
    } catch (error) {
      console.log(error, "error");
      return error;
    }
  },
  options: {
    tags: ["api"],
  },
};
export default route;
